/**
 * Copyright(c) Yystar Technology Co.,Ltd
 */
package com.yystar.security.support.util;


/**
 * String Util class.
 * @author quguilai
 * @date 2013-1-6
 * @todo TODO
 * @modify	<BR>
 * 1.2013-1-6 quguilai Create file.
 */
public class AppStringUtil {
	
	/**
	 * Parse to Int.
	 * @param eventEntry
	 * @return
	 */
	public static int parseInt(String eventEntry) {
		if (isEmpty(eventEntry)) {
			return -1;
		}
		int number = -1;
		try {
			number = Integer.parseInt(eventEntry);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return number;
	}


	/**
	 * Parse to double.
	 * @param entry
	 * @return
	 */
	public static double parseDouble(String entry) {
		if (isEmpty(entry)) {
			return -1.0;
		}
		double number = -1.0;
		try {
			number = Double.parseDouble(entry);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return number;
	}
	
	/**
	 * Parse to double.
	 * @param entry
	 * @return
	 */
	public static long parseLong(String entry) {
		if (isEmpty(entry)) {
			return -1;
		}
		long number = -1;
		try {
			number = Long.parseLong(entry);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return number;
	}

	/**
	 * Check the str is empty or not
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(String str) {
		return str == null || str.equals("");
	}

	

}
